<?php

class UserModel extends Model
{
	public function addUser($name, $password)
	{
		$user['name'] = $name;
		$user['password'] = $password;
		return $this->add($user);
	}
	
	public function getById($id) {
		$condition['id'] = $id;
		$user = $this->where($condition)->find();
		return $user;
	}
	
	public function getAllByPage($record_num) {
		import("ORG.Util.Page"); //  导入分页类 
	 	$count = $this->count();
	 	$Page = new Page ( $count, $record_num );
	 	$show = $Page->show (); //  分页显示输出 
	 	$users = $this->limit ( $Page->firstRow.','.$Page->listRows )->select();
		$result = array('data'=>$users,'page'=>$show);
	 	return $result;
	}
	
	public function getUsersLikeName($name) {
		$condition['name'] = array('like',"%"."a"."%"); 
		return $this->where($condition)->select();
	}
}

?>
